﻿
@using Newtouch.Herp.Infrastructure.Enum
@{
    ViewBag.Title = "配送点";
    Layout = "~/Views/Shared/_Form.cshtml";

}

<form id="form1">
    <div class="container" style="padding:0;">
        <div class="tab-content" style="margin-top:10px;padding-right:10px;">
            <div role="tabpanel" class="tab-pane fade in active">
                <table class="form">
                    <tr>
                        <th class="formTitle">配送点编码：</th>
                        <td class="formValue">
                            <input id="psdbm" name="psdbm" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">配送点名称：</th>
                        <td class="formValue">
                            <input id="psdmc" name="psdmc" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">配送地址：</th>
                        <td class="formValue">
                            <input id="psdz" name="psdz" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">联系人姓名：</th>
                        <td class="formValue">
                            <input id="lxrxm" name="lxrxm" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">联系电话：</th>
                        <td class="formValue">
                            <input id="lxdh" name="lxdh" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">邮政编码：</th>
                        <td class="formValue">
                            <input id="yzbm" name="yzbm" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle">备注信息：</th>
                        <td class="formValue">
                            <input id="bzxx" name="bzxx" type="text" class="form-control" placeholder="" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</form>

<script lang="javascript">

    var keyValue = $.request("keyValue");
    initForm();

    //初始化表单
    function initForm() {
        if (keyValue != null && keyValue != "") {
            $.najax({
                type: "Get",
                url: "/Purchase/QueryLocationbyId",
                data: { Id: keyValue },
                dataType: "json",
                success: function (ajaxresp) {
                    if (ajaxresp !== null) {
                        $("#psdbm").val(ajaxresp.psdbm);
                        $("#psdmc").val(ajaxresp.psdmc);
                        $("#psdz").val(ajaxresp.psdz);
                        $("#lxrxm").val(ajaxresp.lxrxm);
                        $("#ddlx").val(ajaxresp.ddlx);
                        $("#lxdh").val(ajaxresp.lxdh);
                        $("#yzbm").val(ajaxresp.yzbm);
                        $("#bzxx").val(ajaxresp.bzxx);
                    }
                }
            });
        }
    }

    //保存
    function SubmitForm() {
        if (!DataValidate()) {
            return;
        }
        var postData = $("#form1").formSerialize();
        postData.Id = keyValue;
        $.submitForm({
            url: "/Purchase/SubmitLocation",
            param: postData,
            success: function () {
                $.modalMsg('保存成功', 'success');
                $.modalClose();
                callback();
            }
        });
    }

    //数据效验
    function DataValidate() {
        if ($("#psdbm").val() === "") {
            $.modalAlert("配送点编码必填", 'warning');
            return false;
        }
        if ($("#psdmc").val() === "") {
            $.modalAlert("配送点名称必填", 'warning');
            return false;
        }
        if ($("#psdz").val() === "") {
            $.modalAlert("配送地址必填", 'warning');
            return false;
        }
        if ($("#lxrxm").val() === "") {
            $.modalAlert("联系人姓名必填", 'warning');
            return false;
        }
        if ($("#lxdh").val() === "") {
            $.modalAlert("联系电话必填", 'warning');
            return false;
        }
        if ($("#yzbm").val() === "") {
            $.modalAlert("邮政编码必填", 'warning');
            return false;
        }
        return true;
    }


</script>